//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//

package 力扣.题库.未分类.demo20AND40;

public class demo26 {
    public demo26() {
    }

    public static void main(String[] args) {
        int[] nums = new int[]{1, 1, 2};
        System.out.println(removeDuplicates(nums));
    }

    public static int removeDuplicates(int[] nums) {
        if (nums != null && nums.length != 0) {
            int left = 0;

            for(int i = 1; i < nums.length; ++i) {
                if (nums[left] < nums[i]) {
                    ++left;
                    nums[left] = nums[i];
                }
            }

            return left + 1;
        } else {
            return 0;
        }
    }
}
